<template>
	<view class="content" :style="{background:$store.state.bgPrimaryColor}">
		<view class="navBody">
			<view v-for="(item,index) in navs" :key="index"
				:style="{'border-bottom':index !== 1 ? '1px solid #e3e3e3' : '1px solid #fff'}"
				@click="linkUrl(item.url,index)">
				<text>{{item.name}}</text>
				<image src="../../static/more.png"></image>
			</view>
		</view>
		<button :style="{'background':$store.state.buttonColor}" @click="loginout">退出</button>
		<view class="box">
			<u-popup :show="Qrshow" @close="Qrshow = false" @open="Qrshow = true" mode="center" round="20">
				<view class="_popupBody">
					<text class="title">联系我们</text>
					<image :src="shopdetail.kefu_qrcode_text" mode="aspectFit" style="width: 180px;height: 180px;"></image>
					<text class="tips">扫码添加客服微信</text>
					<view class="flex">
						<u-icon size="19" name="phone-fill" color="#333" style="margin:0px auto;"
							@click="Qrshow = false"></u-icon>
						<text>{{shopdetail.mobile || ''}}</text>
					</view>
					<u-icon size="35" name="close-circle-fill" color="#fff" style="margin:0px auto;margin-top:80rpx;"
						@click="Qrshow = false"></u-icon>
				</view>
			</u-popup>
		</view>
	</view>
</template>
<script>
	import {
		userinfo
	} from '../../api/Mine.js';
	import {
		getConfig,
		shopDetail
	} from '../../api/Home.js';
	export default {
		data() {
			return {
				Qrshow: false,
				navs: [{
					url: '/pages/Mine/userinfo',
					name: '个人资料'
				}, {
					url: '/pages/Mine/userinfo',
					name: '联系客服'
				}],
				qrcodeInfo: {},
				shopdetail: {}
				// ,{
				// 	url:'/pages/Mine/userinfo',
				// 	name:'自定义颜色'
				// }
			}
		},
		onShow() {
			this.getConfig();
			this.shopDetail()
		},
		methods: {
			loginout() {
				window.location.href =
					`https://yuekewap.worldtalker.cn/#/pages/Login/LoginHome?shop_id=${uni.getStorageSync('shop_id')}`;
			},
			/**
			@method 获取配置
			**/
			async getConfig() {
				try {
					const res = await getConfig();
					this.qrcodeInfo = {
						...res.data
					};
				} catch (err) {
					//TODO handle the exception
					console.log(err);
				}
			},
			/**
			@method 门店详情
			**/
			async shopDetail() {
				try {
					const res = await shopDetail({
						shop_id: uni.getStorageSync('shop_id') || 1
					});
					this.shopdetail = {
						...res.data
					};
					//this.Qrshow = true;
				} catch (err) {
					//TODO handle the exception
					console.log(err);
				}
			},
			linkUrl(e, index) {
				if (index == 1) {
					this.Qrshow = true;
				} else {
					uni.navigateTo({
						url: e
					});
				}
			}
		}
	}
</script>
<style>
	page {
		background-color: #f7f7f7;
	}
</style>
<style scoped lang="scss">
	button::after {
		border: none;
	}

	.content {
		padding-top: 30px;
		height: 100vh;
		width: 100%;

		._popupBody {
			width: 500rpx;
			height: 480rpx;
			background-color: transparent;

			/deep/ .u-icon {
				display: flex;
				justify-content: center;
			}

			image {
				width: 300rpx;
				height: 500rpx;
				border-radius: 20rpx;
				margin: 0px auto;
				display: block;
			}

			.title {
				display: block;
				font-size: 37rpx;
				font-weight: 500;
				text-align: center;
				margin-top: 20rpx;
				margin-bottom: 20rpx;
			}

			.tips {
				display: block;
				font-size: 24rpx;
				font-weight: 500;
				text-align: center;
				margin-top: 20rpx;
				margin-bottom: 20rpx;
			}

			.flex {
				width: 40%;
				display: flex;
				align-items: center;
				justify-content: center;
				// border:1px solid red;
				margin: 0px auto;
			}
		}

		.navBody {
			width: 80%;
			border-radius: 20rpx;
			margin: 0px auto;
			padding: 20rpx 50rpx 20rpx 50rpx;
			background-color: #fff;

			view {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding-bottom: 30rpx;
				padding-top: 30rpx;

				text {
					font-weight: 500;
					font-size: 29rpx;
				}

				image {
					width: 45rpx;
					height: 45rpx;
				}
			}
		}

		button {
			width: 95%;
			left: 2.5%;
			position: fixed;
			bottom: 40rpx;
			border-radius: 50rpx;
			height: 70rpx;
			color: #fff;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 28rpx; //#277fff
			letter-spacing: 2rpx;
		}
	}
</style>